<template>
  <div>
    <page-content
      ref="contentRef"
      @add-click="handleAddClick"
      @edit-click="handleEditClick"
      :content-config="contentConfig"
      @export-click="handleExportClick"
    >
      <template #isLongTerm="scope">
        <span> {{ scope.row.isLongTerm == 0 ? "否" : "是" }}</span>
      </template>
      <template #type="scope">
        <div>{{ scope.row.type == 1 ? "减金额" : "折扣" }}</div>
      </template>
    </page-content>
    <!-- 新增 -->
    <page-modal
      ref="addModalRef"
      :modal-config="addModalConfig"
      @submit-click="handleSubmitClick"
    />

    <!-- 编辑 -->
    <page-modal
      ref="editModalRef"
      :modal-config="editModalConfig"
      @submit-click="handleSubmitClick"
    />
  </div>
</template>
<script setup>
import UserAPI from "@/api/coupons";
import usePage from "@/hooks/usePage";
import contentConfig from "./config/content";
import addModalConfig from "./config/add";
import editModalConfig from "./config/edit";
const {
  contentRef,
  addModalRef,
  editModalRef,
  handleExportClick,
  handleAddClick,
  handleSubmitClick,
} = usePage();
// 编辑
async function handleEditClick(row) {
  // 根据id获取数据进行填充
  const data = row;
  editModalRef.value?.setModalVisible(data);
}
</script>
<style scoped></style>
